package com.example.demo.service;

import com.example.demo.bean.User;
import com.example.demo.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class UserService {
    @Autowired
    UserDao userDao;

    public User register(User user) {
        User user1 = userDao.saveAndFlush(user);
        return user1;
    }

    public User login(User user) {
        User user1 = userDao.findOne(Example.of(user)).orElse(null);
        return user1;
    }
}
